import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;

public class SimpleTransform {
	
	public static String Transform() throws TransformerException 
	{
/*		javax.xml.transform.TransformerFactory tFactory = javax.xml.transform.TransformerFactory
				.newInstance();

		javax.xml.transform.Transformer transformer = tFactory
				.newTransformer(new javax.xml.transform.stream.StreamSource(
						"birds.xsl"));

		transformer.transform(new javax.xml.transform.stream.StreamSource(
				"birds.xml"), new javax.xml.transform.stream.StreamResult(
				new java.io.FileOutputStream("foo.out")));

		File file = new File("foo.out");
		int ch;
		StringBuffer strContent = new StringBuffer("");
		FileInputStream fin = null;
		try {
			fin = new FileInputStream(file);
			while ((ch = fin.read()) != -1)
				strContent.append((char) ch);
			fin.close();
		} catch (Exception e) {
			System.out.println(e);
		}
		return strContent.toString();*/
		
	    StringReader reader = new StringReader("<xml>blabla</xml>");
	    StringReader xsl = new StringReader("<?xml version=\"1.0\"?>" +
	    		"<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">" +
	    		"<h1>test</h1>" +
	    		"</xsl:stylesheet>");
	    StringWriter writer = new StringWriter();
	    TransformerFactory tFactory = TransformerFactory.newInstance();
	    
	    Transformer transformer = tFactory.newTransformer(
	            new javax.xml.transform.stream.StreamSource(xsl));

	    transformer.transform(
	            new javax.xml.transform.stream.StreamSource(reader), 
	            new javax.xml.transform.stream.StreamResult(writer));
	    

	    return writer.toString();
	    
	}
	
/*	public static void main(String[] args) throws TransformerException,
			TransformerConfigurationException, FileNotFoundException,
			IOException {

		System.out.println(Transform());


	}*/
}
